package com.zhanghu.backendZray.controller.notify;

import com.zhanghu.backendZray.annotation.MenuNeed;
import com.zhanghu.backendZray.pojo.dto.ApiResponse;
import com.zhanghu.backendZray.pojo.request.mail.NotifySettingRequest;
import com.zhanghu.backendZray.pojo.vo.mail.NotifySettingVo;
import com.zhanghu.backendZray.service.NotifySettingService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 通知配置 前端控制器
 * </p>
 *
 * @author zhangdong
 * @since 2024-08-28
 */
@RestController
@RequestMapping("/notifySetting")
@RequiredArgsConstructor
public class NotifySettingController {
    private final NotifySettingService notifySettingService;

    @PostMapping("save")
    @MenuNeed(menuName = "notify_setting")
    public ApiResponse mailSetting(@Validated @RequestBody NotifySettingRequest request) {
        notifySettingService.saveMailSetting(request);
        return ApiResponse.ok();
    }

    @GetMapping("get")
    @MenuNeed(menuName = "notify_setting")
    public ApiResponse<NotifySettingVo> getMailSetting() {
        return ApiResponse.ok(notifySettingService.getMailSetting());
    }
}
